package com.diy.yuhaofilm.ui.activity

import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment
import com.diy.yuhaofilm.R
import com.diy.yuhaofilm.base.BaseActivity
import com.diy.yuhaofilm.util.FragmentUtil
import com.diy.yuhaofilm.util.ToolBarManager
import com.roughike.bottombar.BottomBar
import com.roughike.bottombar.OnTabReselectListener
import com.roughike.bottombar.OnTabSelectListener
import org.jetbrains.anko.find

class MainActivity : BaseActivity(),ToolBarManager {
    var bottomBar:BottomBar?=null

    /**
     * 惰性加载的方式，用的时候才会findviewById
     */
    override val toolbar by lazy { find<Toolbar>(R.id.toobar) }



    override fun getLayoutId(): Int {
        return R.layout.activity_main
    }

    override fun initListener() {
        super.initListener()
        bottomBar?.setOnTabSelectListener {
            // it tabId
           val transation= supportFragmentManager.beginTransaction()
            FragmentUtil.FragmentUtil.getFragment(it)?.let { it1 ->
                transation.replace(R.id.container,
                    it1,it.toString())
            }
            transation.commit()
        }

    }

    override fun initData() {
        super.initData()
        initMainToolBar()
        bottomBar=findViewById(R.id.bottomBar)
    }

}


